package com.seal.yoyoshop.dao.impl;

import com.seal.yoyoshop.bin.Item;
import com.seal.yoyoshop.dao.ItemDao;
import com.seal.yoyoshop.util.DBUtils;

import java.util.List;

public class ItemDaoImpl implements ItemDao {
    @Override
    public boolean insertItem(Item item) {
        String sql = "INSERT INTO item(price, amount, good_id, order_id) VALUES(?, ?, ?, ?)";
        int row = DBUtils.update(sql,item.getPrice(), item.getAmount(),item.getGoodId(),item.getOrderId());
        boolean isSuccess;
        if(row == 1)return true;
        else return false;
    }

    @Override
    public List<Item> SelectItemListByOrderId(int orderId) {
        String sql = "SELECT * FROM item WHERE order_id = ?";
        List<Item> itemList = DBUtils.query(sql,Item.class,orderId);
        return itemList;
    }
}
